import Taro from '@tarojs/taro'
class LogClass {
    log: any
    constructor() {
        this.log = Taro.getRealtimeLogManager ? Taro.getRealtimeLogManager() : null
    }
    info(...arg) {
        if (!this.log) return
        this.log.info(arg)
    }
    warn(...arg) {
        if (!this.log) return
        this.log.warn(arg)
    }
    error(...arg) {
        if (!this.log) return
        this.log.error(arg)
    }
    setFilterMsg(msg) { // 从基础库2.7.3开始支持
        if (!this.log || !this.log.setFilterMsg) return
        if (typeof msg !== 'string') return
        this.log.setFilterMsg(msg)
    }
    addFilterMsg(msg) { // 从基础库2.8.1开始支持
        if (!this.log || !this.log.addFilterMsg) return
        if (typeof msg !== 'string') return
        this.log.addFilterMsg(msg)
    }
}

const log = new LogClass()
export default log
